﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;


namespace Light
{

    /// <summary>
    /// Car的绘图相关部分
    /// </summary>
    partial class Car : UIElement
    {
        Image image = new Image();

        List<String> pathNameList = new List<String>();

        static Random rand = new Random();
       
        public void LoadImage()
        {
            pathNameList.Add( "粉红车.png" );
            pathNameList.Add( "红车.png" );
            pathNameList.Add( "黄车.png" );
            pathNameList.Add( "红车2.png" );

            image.Source = new BitmapImage( new Uri( "Resources/" + pathNameList[ rand.Next( pathNameList.Count ) ], UriKind.Relative ) );
            image.Width = 30;
            image.Height = 30;
            parentCanvas.Children.Add( image );
            Canvas.SetLeft( image, 0 );
            Canvas.SetTop( image, 0 );

            //Canvas.SetZIndex( image, 2 );
        }

        public override void OnUpdate()
        {
            Canvas.SetLeft( image, X );
            Canvas.SetTop( image, Y );
        }

    }
}
